const app = getApp();
var config = require('../../../config');
Page({
  data: {
    logined: false,
    authsetting: 0,
    userinfo: null
  },
  onLoad: function (options) {
    var _this = this;
    app.pageOnLoadInit(this, true).then(function (res) {
      //这里写验证登录成功后且无需验证授权 需要执行的逻辑
      //若还需验证授权成功才执行的逻辑需写在onShow方法里面，
      //并且这里pageOnLoadInit()第二个参数要为 true
      console.log(res);
    }, function (error) {
      // 登录失败
      wx.showModal({
        title: "Error",
        content: error.errMsg ? error.errMsg : 'Fail to login.Please feedback to manager.',
      });
      return false;
    });
  },
  onShow: function () {
    var that = this
    app.pageOnShowInit(that).then(function () {
      //这里写验证授权成功后 需要执行的逻辑
    }, function () {
      //用户没有授权
      console.warn('Auth scope.userInfo is unable.');
      return false;
    });
  },
  href(e) {
    let page = Number(e.currentTarget.dataset.type)
    let url = "";
    switch (page) {
      case 1:
        url = "../userinfo/userinfo"
        break;
      case 2:
        url = "../address/address"
        break;
      default:
        break;
    }
    wx.navigateTo({
      url: url
    })
  }
})